package com.dy.placeOrder.mapper;

import org.apache.ibatis.annotations.Select;
import com.dy.placeOrder.ReceivingAddress;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author author
 * @since 2024-11-20
 */
public interface ReceivingAddressMapper extends BaseMapper<ReceivingAddress> {

//    @Select("<script>" +
//            "SELECT *FROM receiving_address ORDER BY CASE WHEN default_address = 1 THEN 0 ELSE 1 END" +
//            "</script>")
    @Select("<script>" +
            "SELECT *FROM receiving_address WHERE uid=#{uid} ORDER BY CASE WHEN default_address = 1 THEN 0 ELSE 1 END " +
            "</script>")
    List<ReceivingAddress> find(Integer uid);

    @Select("SELECT *FROM receiving_address where id=#{id} ORDER BY CASE WHEN default_address = 1 THEN 0 ELSE 1 END")
//    @Select("SELECT *FROM receiving_address where default_address=1 AND uid=#{uid} ORDER BY CASE WHEN default_address = 1 THEN 0 ELSE 1 END")
    List<ReceivingAddress> finddd(Integer id);

    @Select("<script>" +
            "SELECT *FROM receiving_address where uid=1 ORDER BY CASE WHEN default_address = 1 THEN 0 ELSE 1 END" +
            "</script>")
    List<ReceivingAddress> findAllAddresses();

}
